import java.awt.Dimension;
import java.awt.Point;



public class ClockGeometry
{
	public Point clockCenterPos;
	public int clockRadius, hourHandRadius, minutesHandRadius, hoursTextRadius;
	public String[] hourTextArray = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"};
	private double hoursAngle, minutesAngle;
	
	public ClockGeometry()
	{
		clockCenterPos = new Point(100, 100);
		clockRadius = 90;
		hourHandRadius = 30;
		minutesHandRadius = 60;
		hoursTextRadius = 70;
		hoursAngle = 90;
		minutesAngle = 0;
	}
	
	public Point getHourHandPos()
	{
		Point p = new Point();
		double radians = Math.toRadians(hoursAngle);
		double hourX = clockCenterPos.x + hourHandRadius * Math.cos(radians);
		double hourY = clockCenterPos.y + hourHandRadius * Math.sin(radians);
		p.x = (int) Math.round(hourX);
		p.y = (int) Math.round(hourY);

		return p;
	}
	
	public Point getMinutesHandPos()
	{
		Point p = new Point();
		double radians = Math.toRadians(minutesAngle);
		double hourX = clockCenterPos.x + minutesHandRadius * Math.cos(radians);
		double hourY = clockCenterPos.y + minutesHandRadius * Math.sin(radians);
		p.x = (int) Math.round(hourX);
		p.y = (int) Math.round(hourY);

		return p;
	}
	
	public Point getHoursTextPos(int hour)
	{
		Point p = new Point();
		ArithmeticProgression progression = new ArithmeticProgression(60, -30);
		double nthTerm = progression.nthTerm(hour);
		if(nthTerm < 0) nthTerm = 360 + nthTerm;
		
		double radians = Math.toRadians(nthTerm);
		double hourX = clockCenterPos.x + hoursTextRadius * Math.cos(radians);
		double hourY = clockCenterPos.y + hoursTextRadius * Math.sin(radians);
		p.x = (int) Math.round(hourX);
		p.y = (int) Math.round(hourY);
		
		return p;
	}
	
	public void setHour(int hour)
	{
		ArithmeticProgression progression = new ArithmeticProgression(60, -30);
		double nthTerm = progression.nthTerm(hour);
		if(nthTerm < 0) nthTerm = 360 + nthTerm;
		hoursAngle = nthTerm;
	}
	
	public void setMinutes(int minutes)
	{
		ArithmeticProgression progression = new ArithmeticProgression(90, -30);
		int n = (minutes / 5) + 1; 
		double nthTerm = progression.nthTerm(n);
		if(nthTerm < 0) nthTerm = 360 + nthTerm;
		minutesAngle = nthTerm;
	}
}
